package com.ngu.config;

import com.baomidou.mybatisplus.core.injector.ISqlInjector;
import com.baomidou.mybatisplus.extension.injector.LogicSqlInjector;
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import com.baomidou.mybatisplus.extension.plugins.PerformanceInterceptor;
import org.mybatis.spring.mapper.MapperScannerConfigurer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
* @ClassDescription:    数据操作层配置
* @Author:         HSJ
* @CreateDate:     2020/3/2 11:32
*/
@Configuration
public class MybatisConfig {

    @Bean
    public PaginationInterceptor paginationInterceptor()  {
        return new PaginationInterceptor();
    }


    /**
    * @ClassDescription:    扫描dao包
    * @Author:         hsj
    * @CreateDate:     2020/3/2 11:30
    */
    @Bean
    public MapperScannerConfigurer MapperScannerConfigurer(){
        MapperScannerConfigurer scannerConfigurer = new MapperScannerConfigurer();
        scannerConfigurer.setBasePackage("com.ngu.**.dao");
        return scannerConfigurer;
    }

    /**
    * @ClassDescription:    打印sql 及查询耗时
    * @Author:         hsj
    * @CreateDate:     2020/3/2 11:30
    */
//    @Bean
//    public PerformanceInterceptor performanceInterceptor() {
//        PerformanceInterceptor performanceInterceptor = new PerformanceInterceptor();
//        //是否格式化：false不格式化、true格式化。
//        performanceInterceptor.setFormat(false);
//        return performanceInterceptor;
//    }

    /**
    * @MethodDescription:    逻辑删除和查询配置
    * @Author:      hsj
    * @CreateDate:       2020/3/4 15:50
    */
    @Bean
    public ISqlInjector sqlInjector() {
        return new LogicSqlInjector();
    }



}
